<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
<!--        <a-row :gutter="24">-->
<!--          <a-col :md="6" :sm="8">-->
<!--            <a-form-item label="机构">-->
<!--              <j-select-depart v-model="queryParam.office"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :md="6" :sm="8">-->
<!--            <a-form-item label="系统名称" :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}">-->
<!--              <a-input placeholder="请输入系统名称查询" v-model="queryParam.systemName"></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->

<!--        </a-row>-->
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
           <a-form-item
            :labelCol="labelCol"
            :wrapperCol="wrapperCol"
            label="时间">
             <a-select v-model="queryParam.years" @change="dateChange(queryParam.years)">
               <a-select-option v-for="item in years"
                                :label="item.label"
                                :value="item.value">{{item.label}}
               </a-select-option>
             </a-select>
        </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :md="12" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a-button type="primary" icon="" @click="payMoney" style="margin-left: 8px">结算</a-button>
              <a-button type="primary" icon="" @click="handlePayMoney" style="margin-left: 8px">结算清单</a-button>
<!--              <a-button type="primary" icon="download" @click="handleExportXls('云资源审核清单')" style="margin-left: 8px">审核清单</a-button>-->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
        
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="图片不存在" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

<!--        <span slot="action" slot-scope="text, record">-->
<!--          <a @click="handleAdd(record)">结算</a>-->
<!--        </span>-->
      </a-table>
    </div>

    <cloud-service-money-model ref="modalForm" @ok="modalFormOk"></cloud-service-money-model>
    <cloud-service-pay-money-model ref="modalPayForm" @ok="modalFormOk"></cloud-service-pay-money-model>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import cloudServiceMoneyModel from './modules/cloudServiceMoneyModel'
  import cloudServicePayMoneyModel from './modules/cloudServicePayMoneyModel'
  import JDate from '@/components/jeecg/JDate.vue'
  import {initDictOptions, filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
  export default {
    name: "cloudServiceMoneyList",
    mixins:[JeecgListMixin],
    components: {
      JDate,
      cloudServiceMoneyModel,
      cloudServicePayMoneyModel,
      JSelectDepart
    },
    data () {
      return {
        selectedRowKeys: [],
        /* table选中records*/
        selectionRows: [],
        queryParam:{
          systemName:'',
          office:'',
          years:''
        },
        description: '',
        // 表头
        columns: [
          {
            title: '序号',
            align: "center",
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title:'区县',
            align:"center",
            dataIndex: 'sysOrgCodeName',

          },
          {
            title:'单位名称',
            align:"center",
            dataIndex: 'officeName',
          },
          {
            title:'系统名称',
            align:"center",
            dataIndex: 'systemName'
          },
          {
            title:'云服务器名称',
            align:"center",
            dataIndex: 'serverName'
          },
          {
            title: '审核配置',
            children: [
              {
                title: 'CPU',
                align: "center",
                dataIndex: 'auditCpu'
              },
              {
                title: '内存',
                align: "center",
                dataIndex: 'auditMemory'
              },
              {
                title: '云硬盘',
                align: "center",
                dataIndex: 'auditDisk'
              },
            ]
          },
          {
            title:'数据库',
            align:"center",
            width: '8%',
            dataIndex: 'dataBase_dictText'
          },
          {
            title:'开通时间',
            align:"center",
            width: '8%',
            dataIndex: 'openTime'
          },

          {
            title:'上次结算时间',
            align:"center",
            width:'7%',
            dataIndex: 'lastPayTime',
          },
          {
            title:'未结算时长',
            align:"center",
            dataIndex: 'noSetTime',
          },
          {
            title:'年云服务费',
            align:"center",
            width:'7%',
            dataIndex: 'yearMoney',
          },
          {
            title:'本期云服务费',
            align:"center",
            width:'7%',
            dataIndex: 'lastYearMoney',
          },
          // {
          //   title: '操作',
          //   dataIndex: 'action',
          //   align:"center",
          //   width:'7%',
          //   scopedSlots: { customRender: 'action' },
          // }
        ],
        url: {
          list: "/jinanCloud/cloudServiceProject/cloudManageList",
          // exportXlsUrl: "/jinanAudit/auditMain/exportXls",
        },
        dictOptions:{
         office:[],
         tos:[],
        } 
      }
    },
    computed: {

      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    mounted() {
      this.init();
    },
    methods: {
      init(){
        this.getYear();
      },
      dateChange(obj){
        console.log(obj);
      },
      getYear(){//获取年
        let date = new Date();
        let current_year = date.getFullYear();
        // this.queryParam.yearDate=current_year;
        this.years=[];
        for (let i = 0; i < 30; i++) {
          let y = current_year - i;
          this.years.push({value:(y),label:(y)+ "年"});
          // this.yearDate.push(y);
          if(y=='1970'){
            return
          }
        }
      },
      onSelectChange(selectedRowKeys, selectionRows) {
        this.selectedRowKeys = selectedRowKeys;
        this.selectionRows = selectionRows;
      },
      onClearSelected() {
        this.selectedRowKeys = [];
        this.selectionRows = [];
      },
      handleAdd: function (record) {
        this.$refs.modalForm.edit(record);
        this.$refs.modalForm.title = "结算";
        this.$refs.modalForm.disableSubmit = true;
      },
      payMoney: function () {
        if (this.selectedRowKeys.length <= 0) {
          this.$message.warning('请选择一条记录！');
          return false;
        } else {
          this.$refs.modalPayForm.edit(this.selectionRows);
          this.$refs.modalPayForm.title = "结算";
          this.$refs.modalPayForm.disableSubmit = true;
        }
      },
      handlePayMoney: function (record) {
        //带参数跳转
        this.$router.push({name:'jinan-cloudApply-settlementFeeList',query:{}});

      },
       
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>